<template>
  <div>
    <el-row :gutter="20">
      <el-col :span="16">
        <el-input
          v-model="searchParam.q"
          placeholder="请输入搜索内容"
        ></el-input>
      </el-col>
      <el-col :span="8">
        <el-button type="primary" @click="search()">搜索</el-button>
      </el-col>
    </el-row>
    <el-table :data="listResult.subs" style="width: 80%">
      <el-table-column prop="id" label="字幕ID" width="120"> </el-table-column>
      <el-table-column prop="native_name" label="影片原始名称">
      </el-table-column>
      <el-table-column prop="revision" label="修订版本ID" width="120">
      </el-table-column>
      <el-table-column prop="upload_time" label="上传时间" width="160px">
      </el-table-column>
      <el-table-column prop="subtype" label="字幕格式 " width="150px">
      </el-table-column>
      <el-table-column prop="vote_score" label="评分" width="120">
      </el-table-column>
      <el-table-column prop="lang.desc" label="语言" width="160">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { queryAssrt, queryAssrtDetail } from "../js/subMethods";
export default {
  name: "index",
  components: {},
  data() {
    return {
      searchParam: {
        q: "",
        pos: 1,
        cnt: 15,
        is_file: 0,
        no_muxer: 0,
        filelist: 0,
      },
      listResult: "",
      detailResult: "",
    };
  },
  methods: {
    async search() {
      try {
        let parma = `q=${this.searchParam.q}&pos=${this.searchParam.pos}&cnt=${this.searchParam.cnt}
                    &is_file=${this.searchParam.is_file}&no_muxer=${this.searchParam.no_muxer}
                    &filelist=${this.searchParam.filelist}`;
        let { status, data } = await queryAssrt(parma);
        if (status == 200) {
          this.listResult = data.sub;
        }
      } catch (error) {
        console.log(error);
      }
    },
    async getDetail(id) {
      try {
        let parma = `id=${id}`;
        let { status, data } = await queryAssrtDetail(parma);
        if (status == 200) {
          this.detailResult = data.sub.subs;
        }
      } catch (error) {
        console.log(error);
      }
    },
  },
};
</script>
